<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s"  uri="/struts-tags" %>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
   	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <link href="<%=request.getContextPath()%>/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="<%=request.getContextPath()%>/js/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script src="<%=request.getContextPath()%>/js/bootstrap.js" type="text/javascript"></script>  
    
        
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrapValidator.css"/>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrapValidator.js"></script>
    
    
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/lhdialog/lhgcore.min.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/lhdialog/lhgdialog.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/OpenDialog.js"></script>

    <script type="text/javascript">
    
    $(document).ready(function() {
    	
    	$('#defaultForm')
        .bootstrapValidator({
            message: 'This value is not valid',
            fields: {
                "t.name": {
                    validators: {
                        notEmpty: {
                            message: '商品系列名称不能为空'
                        }
                    }
                },
                "t.isKeyAttr": {
                    validators: {
                        notEmpty: {
                            message: '是否为属性键不能为空'
                        }
                    }
                }
            }
        })
    });
    
    function chooseSupplier(){
    	var titleText = "";
  		PUBLICOBJECT.id = "entid";
  		PUBLICOBJECT.title = titleText;
  		PUBLICOBJECT.width = "500";
  		PUBLICOBJECT.height = "auto";
  		PUBLICOBJECT.titleText = titleText;
  		PUBLICOBJECT.page = "<%=request.getContextPath()%>/supplier/Supplier_listByPage?params=choose";
  		var rs = PUBLICOBJECT.openLab();
  		rs.ShowDialog();// 打开弹出窗
  		var dom = window.frames["lhgfrm_" + PUBLICOBJECT.id];// 弹出框document对象
  		rs.addBtn(PUBLICOBJECT.id, "确定", function() {
  			var _choose = $(dom.document).find("input[name='idChoose']:checked");
  			var chooseValue = _choose.val();
  			if(chooseValue != null){
  				rs.cancel();// 关闭当弹出窗
  				var chooseName = _choose.siblings("input[name='nameChoose']").val();
  				//将选择的值放入页面
  				$("#supplierId").val(chooseValue);
  				$("#supplierName").val(chooseName);
  			}else{
  				alert("请选择一项");
  			}
  		}, "left");
    }

    </script>
</head>
<body>
<div class="panel panel-primary">
  <div class="panel-heading">添加属性映射${params=='update' }</div>
  <div class="panel-body">
    
	  <form id="defaultForm" class="form-horizontal" 
	  	action=<c:if test="${params=='add' }">"<%=request.getContextPath()%>/productAttr/ProductAttrMapping_add"</c:if> 
	  	<c:if test="${params=='update' }">"<%=request.getContextPath()%>/productAttr/ProductAttrMapping_update"</c:if>
	  	method="post">
	    
	  	<div class="form-group">
	  	<input type="hidden" value="${t.id }" name="t.id">
		     <label class="col-sm-5 control-label" id="productIntroductionNameMng">供应商：</label>
		     <div class="col-sm-2">
                <input class="form-control" type="text" id="supplierName" readonly="readonly" value="${t.supplier.name }" onchange="checkName('productIntroductionName')">
                <input type="hidden" id="supplierId" name="t.supplier.id" value="${t.supplier.id }">
                <input type="hidden" value="${t.MAttrId }" name="t.MAttrId">
                <div class="check" style="color:#a94442;font-size:85%"><span class="checkMsg"></span></div>
		     </div>
		     <div class="col-sm-2">
                <input class="form-control" type="button" value="选择供应商" onclick="chooseSupplier()">
		     </div>
		 </div> 
	  	<div class="form-group">
		     <label class="col-sm-5 control-label" id="productIntroductionNameMng">分类名称：</label>
		     <div class="col-sm-2">
                <input class="form-control" type="text" name="t.categoryName" value="${t.categoryName }" onchange="checkName('productIntroductionName')">
                <div class="check" style="color:#a94442;font-size:85%"><span class="checkMsg"></span></div>
		     </div>
		 </div> 
	  	<div class="form-group">
		     <label class="col-sm-5 control-label" id="productIntroductionNameMng">属性组名称：</label>
		     <div class="col-sm-2">
                <input class="form-control" type="text" name="t.attrGroupName" value="${t.attrGroupName }" onchange="checkName('productIntroductionName')">
                <div class="check" style="color:#a94442;font-size:85%"><span class="checkMsg"></span></div>
		     </div>
		 </div> 
	  	<div class="form-group">
		     <label class="col-sm-5 control-label" id="productIntroductionNameMng">属性名称：</label>
		     <div class="col-sm-2">
                <input class="form-control" type="text" name="t.attrName" value="${t.attrName }" onchange="checkName('productIntroductionName')">
                <div class="check" style="color:#a94442;font-size:85%"><span class="checkMsg"></span></div>
		     </div>
		 </div> 
		 
		  <div class="form-group">
		    <div class="col-sm-offset-5 col-sm-7">
		      <button type="submit" class="btn btn-default">提交</button>
		      <button type="reset" class="btn btn-default">重置</button>
		    </div>
		  </div>
      </form>
    
  </div>
  
</div>

</body>
</html>
